package DigitalNetwork;

import java.awt.Graphics;
import java.awt.Color;

public class GeneratorView extends UnitView {

    /** [Konstruktor]
     * Hozzaadja a Unitot a View-hoz.
     */
	//==========================================================================
    public GeneratorView(Unit u){
        super(u);
    }
    //==========================================================================

	/**
	 * 
	 * @param g
	 * @return 
	 */
    @Override
	public void draw(Graphics g) {
		// A tartalmazott Unit kasztolasa Generatorra-ra
        Generator gen = (Generator)this.unit;

        // Keret es UnitID szine
        g.setColor(Color.BLACK);

        // Keret kirajzolasa
        g.drawRoundRect(0, 0, NetworkView.UNIT_SIZE, NetworkView.UNIT_SIZE, 20, 20);
        g.drawString(gen.getID(), 2, NetworkView.UNIT_SIZE/2 + 5 );

        // Generator aktualis ertekenek szine (1 - zold | 0 - piros)
        if(gen.getIsHigh()){
            g.setColor(Color.GREEN);
        } else {
            g.setColor(Color.RED);
        }

        // Button ertekenek kirajzolasa
        g.drawString(gen.getIsHigh() ? "[1]" : "[0]", NetworkView.UNIT_SIZE - 15, NetworkView.UNIT_SIZE/2 + 5 );
	}

}